<template>
	<view class="" style="height: 100vh;padding: 50rpx;">
		<view class="" style="height: 20%;padding-top: 30rpx;">
			<view class="" style="font-size: 50rpx;">
				账号登陆
			</view>
			<view class="" style="font-size: 28rpx;color: #adadad;margin-top: 20rpx;">
				欢迎登录盛博灿管理系统
			</view>
		</view>
		<view class="">
			<view class="">
				<u-form :model="form" ref="uForm">
					<view class="">
						<u-form-item label="账号:"><u-input v-model="form.account" placeholder="请输入账号" /></u-form-item>
					</view>
					<view class="" style="margin-top: 50rpx;">
						<u-form-item label="密码:"><u-input v-model="form.password" type="password" placeholder="请输入密码" /></u-form-item>
					</view>
					
				</u-form>
			</view>
			<view class="" style="margin-top: 120rpx;">
				<u-button type="primary" shape="circle" @click="Login()">登录</u-button>
			</view>
		</view>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form: {
					account: '',
					password: ''
					// account: 'wangwu',
					// password: '123456'
				}
			}
		},
		methods: {
			async Login(){
				const res = await this.$api.login({'account':this.form.account,'password':this.form.password})
				console.log(res)
				if(res.code==1){
					uni.setStorageSync('userinfo', JSON.stringify(res.data.userinfo))
					uni.setStorageSync('token', res.data.userinfo.token)
					uni.switchTab({
						url: '/pages/index/index'
					})
				}else{
					this.$refs.uToast.show({
						title: res.msg,
						type: 'error'
					})
				}
				
			}
		}
	}
</script>

<style lang="scss">
	
</style>
